<?php
include 'dbconfig.php';
include 'opendb.php';

$ID= $_GET['projectID'];
$where  = $ID?   "where PROJECT_ID=$ID" : "";


$doc = new DomDocument ('1.0', 'utf-8');
$root = $doc->appendChild ($doc->createElement ('assets'));

function insertEntry ($node, $entry) {
	$node->appendChild ($entry);
}

$rows = mysql_query ("SELECT RES_ID,RES_NAME,RES_TITLE,DESCRIPTION FROM wp_asset $where");

/*$rows = mysql_query ("SELECT $fields FROM $table $where $orderBy");*/
if ($rows) {
	while ($row = mysql_fetch_assoc ($rows)) {
		$entry = $doc->createElement ('asset');
		foreach ($row as $fieldName => $fieldValue) {
			$field = $entry->appendChild ($doc->createElement ($fieldName));
			$field->appendChild ($doc->createTextNode ($fieldValue));
		}
		insertEntry ($root, $entry);
	}
}


header ('Content-Type: text/xml');
echo $doc->saveXML ();
?>